<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <title>snsmi | Popular and highly playable games</title>
  <meta name="description"
    content="Snsmi is a website that offers free games to play for you. Our mission is to provide a safer, better and more fun gaming experience for people all over the world. This includes but is not limited to puzzle games, action games, sports games, racing games, shooting games, arcade games, make-up games, matching games, cooking games and many more.You can play your favourite games through our website for free on different devices, whether it is a computer, tablet, Android phone or iPhone.">
  <script async src="./js/rem_adaptive.min.js"></script>
  <script>
    if (window.screen.width < 768) {
      document.documentElement.style.fontSize = window.innerWidth / 640 * 100 + 'px';
    }
  </script>
</head>
<link rel="icon" href="./img/icon_game.png" type="image/x-icon">
<link rel="stylesheet" href="./css/index.css">
<link rel="stylesheet" href="./css/share.css">
<link rel="preconnect" href="https://pagead2.googlesyndication.com">
<link rel="preconnect" href="https://www.googletagmanager.com">

<link rel="manifest" href="manifest.json">

<style>
  [v-cloak] {
    display: none;
  }
</style>

<body>
  <div id="app" v-cloak>
    <div class="main">
      <div class="header">

        <!-- pc_categories -->
        <a :href="`index.html?gameChannelId=${gameChannelId}${camp}${groupId}`" class="logo">
          <img src="./img/logo.png" alt="logo" width="125" height="60">
        </a>
        <a class="label" :href="handleTypeGames(cate.type)" v-for="cate in categories" :key="cate.type">
          <i class="label_icon">
            <img :src="cate.imgUrl" :alt="cate.type" width="30" height="30">
          </i>
          <span class="label_name">
            {{cate.name}}
          </span>
        </a>


        <!-- mobile_categories -->
        <div class="home-icon" @click="handleHideLabel"><img src="./img/list.png" alt="list"></div>

        <div class="label-panel" :style="{display: labelHide ? 'block' : 'none'}">
          <a class="label-container" :href="handleTypeGames(cate.type)" v-for="cate in categories" :key="cate.type">
            <i class="label_icon">
              <img :src="cate.imgUrl" :alt="cate.type" width="30" height="30">
            </i>
            <span class="label-name">{{cate.name}}</span>
          </a>
        </div>

        <!-- search -->
        <div class="search">
          <div class="search-menu">
            <input class="search_input" type="text" v-model="search" @focus="showSearchTable = true" placeholder="Search Game...">
            <div class="search-btn" @click="handleToSearch">
              <img class="search-btn_img" src="./img/icon-search.png" alt="search_icon" width="20">
            </div>
            <div class="search-table" v-show="search.length > 0 && showSearchTable">
              <div class="search-loading" v-if="!searchDone">
                <img src="./img/loading.gif" alt="loading" width="50">
              </div>
              <ul v-else-if="searchDone && searchResult.length > 0">
                <li v-for="item in searchResult" :key="item.gameId">
                  <a :href="`${handleDetail(item)}&keyword=${item.gameName}`">
                    <span class="game-name">{{item.gameName}}</span>
                  </a>
                </li>
              </ul>
              <div v-else class="search-loading">
                Search result is null
              </div>
            </div>
          </div>
        </div>

        
        <a class="to-search" :href="`search.html?gameChannelId=${gameChannelId}${camp}${groupId}`">
          <img src="./img/search.png" alt="search_icon" width="35">
        </a>

      </div>

      <div class="share">
        <a href="https://www.facebook.com/sharer.php?t=Fun game sharing&u=https://ads.snsmi.com/forecast/adbee"
          aria-label="To facebook">
          <img src="./img/facebook.png" alt="share_facebook" width="40" height="40">
        </a>
        <a href="https://twitter.com/intent/tweet?text=Fun game sharing&url=https://ads.snsmi.com/"
          aria-label="To twitter">
          <img src="./img/twitter_02.png" alt="share_twitter" width="40" height="40">
        </a>
        <a href="https://www.snapchat.com/scan?attachmentUrl=https://ads.snsmi.com/" aria-label="To snapchat">
          <img src="./img/snapchat.png" alt="share_snapchat" width="40" height="40">
        </a>
        <a href="#" @click="handleShare" aria-label="Share ads.snsmi.com">
          <img src="./img/share.png" alt="share" width="40" height="40">
        </a>
      </div>
      <div class="share_wap">
        <a href="#" @click="handleShare" aria-label="Share ads.snsmi.com">
          <img src="./img/share_02.png" alt="share">
        </a>
      </div>
      <div class="share_box" v-show="shareStauts" aria-label="To facebook">
        <a href="https://www.facebook.com/sharer.php?t=Fun game sharing&u=https://ads.snsmi.com/forecast/adbee">
          <img src="./img/facebook.png" alt="share_facebook"> Facebook
        </a>
        <a href="https://twitter.com/intent/tweet?text=Fun game sharing&url=https://ads.snsmi.com/"
          aria-label="To twitter">
          <img src="./img/twitter_02.png" alt="share_twitter"> Twitter
        </a>
        <a href="https://www.snapchat.com/scan?attachmentUrl=https://ads.snsmi.com/" aria-label="To snapchat">
          <img src="./img/Snapchat_02.png" alt="share_snapchat"> Snapchat
        </a>
        <a href="https://www.linkedin.com/shareArticle?mini=true&title=Fun game sharing&utl=https://ads.snsmi.com/"
          aria-label="To linkedin">
          <img src="./img/linkedin.png" alt="share_linkedin"> Linkedin
        </a>
        <a href="mailto:?subject=Fun game sharing&body=https://ads.snsmi.com/" aria-label="To email">
          <img src="./img/email.png" alt="share_email"> Email
        </a>
        <a href="https://web.skype.com/share?utl=https://ads.snsmi.com/&text=Fun game sharing" aria-label="To skype">
          <img src="./img/skype.png" alt="share_skype"> Skype
        </a>
        <a href="https://reddit.com/submit?utl=https://ads.snsmi.com/&title=Fun game sharing" aria-label="To reddit">
          <img src="./img/reddit.png" alt="share_reddit"> Reddit
        </a>
        <a href="https://www.tumblr.com/widgets/share/tool?canonicalUrl=https://ads.snsmi.com/&title=Fun game sharing"
          aria-label="To tumblr">
          <img src="./img/tumblr.png" alt="share_tumblr"> Tumblr
        </a>
      </div>
      <div class="closeShare" v-show="shareStauts" @click="handleShare">
        <img src="./img/close.png" alt="close">
      </div>
      <div class="more_share_bg" v-show="shareStauts" @click="handleShare"></div>
      <div class="posterBanner top" ref="poster" style="height: auto !important; width: 100%;" v-html="poster">

      </div>

      <div class="content">
        <div class="recommend">
          <div class="title">
            <img src="./img/game.png" alt="game" width="64" height="64">
            <span class="text">
              Recommend Games
            </span>
          </div>
          <div class="recommendGameList">
            <a :href="handleDetail(item)" class="game scroll" v-for="item in recommendGameList" :key="item.gameId">
              <img src="./img/picture.gif" class="pic" :data-src="item.gameLogo" :alt="item.gameName" width="200"
                height="200">
              <span class="name">{{item.gameName}}</span>
            </a>
          </div>
        </div>
        <div class="midGames-box">
          <div class="midGames-title">
            <img src="./img/game.png" alt="game" width="32" height="32">
            <span class="midGames-title__text">
              Recommend Games
            </span>
          </div>
          <div class="midGames">
            <a class="l_box scroll" :href="handleDetail(item)" v-for="item in midGameList" :key="item.gameId">
              <img src="./img/picture.gif" :data-src="item.gameLogo" class="pic" :alt="item.gameName" width="100"
                height="100" fetchpriority="high">
              <!-- <div class="name">{{item.gameName}}</div> -->
            </a>
          </div>
        </div>
      </div>
      <div class="posterBanner" v-html="poster2" ref="poster2">
      </div>
      <!-- 滑动 -->

      <div class="content block">
        <div class="newGames">
          <div class="title">
            <img src="./img/newGame.png" alt="new_game" width="32" height="32">
            <div class="text">
              Newest Games
            </div>
          </div>
          <div class="newGamesContent">
            <a class="box-container scroll" :href="handleDetail(item)" v-for="(item,index) in newGameList"
              :key="item.gameId" @mouseover="handleSetNewsGame(index)">
              <div class="wrapper">
                <img src="./img/picture.gif" class="pic lazyload fmt" :data-src="item.gameLogo" :alt="item.gameName"
                  width="160" height="160">
              </div>
            </a>
          </div>
        </div>
        <div class="bigGames">
          <div class="title">
            <img src="./img/sprite.png" alt="sprite" width="32" height="32">
            <span class="text">FEATURED & RECOMMENDED</span>
          </div>
          <div class="m-list">
            <a class="m-box scroll" :href="handleDetail(item)" v-for="item in bigGameList" :key="item.gameId">
              <img src="./img/picture.gif" class="pic lazyload fmt" :data-src="item.gameLogo" :alt="item.gameName"
                width="100" height="100" fetchpriority="low">
              <div class="name">{{item.gameName}}</div>
              <div class="type">{{item.type}}</div>
              <div class="rating"><span class="text">{{item.rating}}</span></div>
              <div class="cloud"><span class="text">{{(item.gamePlayNumber/10000).toFixed(2)}}W</span></div>
            </a>
          </div>
        </div>
      </div>

      <!-- <div class="posterBanner banner" ref="poster3">
        
      </div> -->

      <div class="content block">
        <div class="delicateGames">
          <div class="title">
            <img src="./img/delicate.png" alt="delicate" width="32" height="32">
            <div class="text">POPULAR & DELICATE</div>
          </div>
          <div class="p-list">
            <a class="delicate-box scroll" :href="handleDetail(item)" v-for="item in delicateGames" :key="item.gameId">
              <div class="box">
                <img src="./img/picture.gif" class="pic lazyload fmt" :data-src="item.gameLogo" :alt="item.gameName"
                  width="100" height="100" fetchpriority="low">
                <div class="game-info">
                  <div class="game-name">{{item.gameName}}</div>
                  <div class="game-description">{{item.gameDesc}}</div>
                </div>
              </div>
            </a>
          </div>
        </div>
      </div>

      <div class="swiper-container">
        <div class="swiper-container-title">
          <h3>Casual Games</h3>
          <a :href="handleTypeGames('casual')">See All</a>
        </div>
        <div class="swiper-left__button" v-show="left != 0" @click="handleScrollLeft">
          <img class="img" src="./img/arrow-left.png" alt="arrow-left">
        </div>
        <div class="swiper-right__button" @click="handleScrollRight">
          <img class="img" src="./img/arrow-right.png" alt="arrow-right">
        </div>
        <div class="swiper-container-main">
          <div class="swiper-container-main__wrapper" ref="swiperContainer" :style="slideStyle"
            @mousedown.prevent="siwperMouseDown" @mouseup="clearMouseMove">
            <a class="swiper-container-main__item" :href="handleDetail(item)" v-for="item in racingGames">
              <div class="swiper-item">
                <div class="swiper-item__img">
                  <img src="./img/picture.gif" class="img pic lazyload fmt scroll" :data-src="item.gameLogo"
                    :alt="item.gameName" width="250" height="250">
                  <div class="swiper-item-detail">
                    <div class="swiper-item-detail__name">{{ item.gameName }}</div>
                    <div class="swiper-item-detail__desc">{{ item.gameDesc }}</div>
                  </div>
                </div>
                <div class="swiper-item__name">{{ item.gameName }}</div>
              </div>
            </a>
          </div>
        </div>
      </div>

      <div class="swiper-container">
        <div class="swiper-container-title">
          <h3>Shooter Games</h3>
          <a :href="handleTypeGames('shooter')">See All</a>
        </div>
        <div class="swiper-left__button" v-show="left2 != 0" @click="handleScrollLeft2">
          <img class="img" src="./img/arrow-left.png" alt="arrow-left">
        </div>
        <div class="swiper-right__button" @click="handleScrollRight2">
          <img class="img" src="./img/arrow-right.png" alt="arrow-right">
        </div>
        <div class="swiper-container-main">
          <div class="swiper-container-main__wrapper" ref="swiperContainer2" :style="slideStyle2"
            @mousedown.prevent="siwperMouseDown2" @mouseup="clearMouseMove2">
            <a class="swiper-container-main__item" :href="handleDetail(item)" v-for="item in shootGames">
              <div class="swiper-item">
                <div class="swiper-item__img">
                  <img src="./img/picture.gif" class="img pic lazyload fmt scroll" :data-src="item.gameLogo"
                    :alt="item.gameName" width="250" height="250">
                  <div class="swiper-item-detail">
                    <div class="swiper-item-detail__name">{{ item.gameName }}</div>
                    <div class="swiper-item-detail__desc">{{ item.gameDesc }}</div>
                  </div>
                </div>
                <div class="swiper-item__name">{{ item.gameName }}</div>
              </div>
            </a>
          </div>
        </div>
      </div>

      <div class="swiper-container">
        <div class="swiper-container-title">
          <h3>Girls Games</h3>
          <a :href="handleTypeGames('girl')">See All</a>
        </div>
        <div class="swiper-left__button" v-show="left3 != 0" @click="handleScrollLeft3">
          <img class="img" src="./img/arrow-left.png" alt="arrow-left">
        </div>
        <div class="swiper-right__button" @click="handleScrollRight3">
          <img class="img" src="./img/arrow-right.png" alt="arrow-right">
        </div>
        <div class="swiper-container-main">
          <div class="swiper-container-main__wrapper" ref="swiperContainer3" :style="slideStyle3"
            @mousedown.prevent="siwperMouseDown3" @mouseup="clearMouseMove3">
            <a class="swiper-container-main__item" :href="handleDetail(item)" v-for="item in girlsGames">
              <div class="swiper-item">
                <div class="swiper-item__img">
                  <img src="./img/picture.gif" class="img pic lazyload fmt scroll" :data-src="item.gameLogo"
                    :alt="item.gameName" width="250" height="250">
                  <div class="swiper-item-detail">
                    <div class="swiper-item-detail__name">{{ item.gameName }}</div>
                    <div class="swiper-item-detail__desc">{{ item.gameDesc }}</div>
                  </div>
                </div>
                <div class="swiper-item__name">{{ item.gameName }}</div>
              </div>
            </a>
          </div>
        </div>
      </div>

      <!-- <a style="display: block;max-width: 250px;margin: 0 auto;margin-top: 10px;" href="https://ttgrxyx.com/" target="_blank">
        <img style="width: 100%;" src="./img/lnk.jpg" alt="">
      </a> -->
      
      <!-- 手机底部类型列表 -->
      <section v-if="mobile" class="categories">
        <div class="label-panel">
          <a class="label-container" :href="handleTypeGames(cate.type)" v-for="cate in categories" :key="cate.type">
            <i class="label_icon">
              <img :src="cate.imgUrl" :alt="cate.type">
            </i>
            <span class="label-name">{{cate.name}}</span>
          </a>
        </div>
      </section>

      <section class="moregame">
        <div class="moregame-tite">
          More online games
        </div>
        <div class="list">
          <a class="list-item" :href="handleDetail(game)" v-for="game in moreGames" :key="game.gameId">
            <div class="list-item-wrapper">
              <img class="wrapper-img" :src="game.gameLogo" :alt="game.gameName" width="190" height="190">
            </div>
            <div class="list-item-name">
              <p class="list-item-name__text">{{game.gameName}}</p>
            </div>
          </a>
        </div>
      </section>

      <div class="footer">
        <div class="bottom-navbar">
          <a :href="handleToAboutContent('cookies')">
            Cookies
          </a>
          <a :href="handleToAboutContent('privacy')">
            Privacy Policy
          </a>
          <a href="mailto:linyating2000@gmail.com" target="_blank">Contact Us</a>
          <a :href="handleToAboutContent('company')">
            About Us
          </a>
        </div>
      </div>
    </div>

    <div class="back" v-show="backTop" @click="handleBackTop">
      <img src="./img/back_top.png" alt="backTop" width="25" height="25">
    </div>
  </div>
</body>

<script src="./js/main.js"></script>
<script src="./js/sliderGames.js"></script>
<script src="./js/afg.js"></script>

<script src="./js/vue.min.js"></script>
<script src="./js/axios.min.js"></script>
<script src="./js/loadMoreGames.js"></script>
<script src="./js/accountData.js"></script>
<script src="./js/collet-data.js"></script>
<script>
  function debounce(fn, delay) {
    let timer = null
    return function () {
      let that = this
      let args = arguments
      if (timer) {
        clearTimeout(timer)
      }
      timer = setTimeout(() => {
        fn.apply(that, args)
        clearTimeout(timer)
        timer = null
      }, delay)
    }
  }
</script>
<script>
  var vm = new Vue({
    el: "#app",
    data() {
      return {
        categories: [
          {
            name: 'Hot Games',
            type: 'hot',
            imgUrl: './img/hot.png'
          },
          {
            name: 'Racing Games',
            type: 'racing',
            imgUrl: './img/racing-game.png'
          },
          {
            name: 'Shooter Games',
            type: 'shooter',
            imgUrl: './img/shooting-game.png'
          },
          {
            name: 'Action Games',
            type: 'action',
            imgUrl: './img/action-game.png'
          },
          {
            name: 'Casual Games',
            type: 'casual',
            imgUrl: './img/casual.png'
          },
          {
            name: 'Girls Games',
            type: 'girl',
            imgUrl: './img/girls.png'
          }
        ],
        backTop: false,
        moreGames: [],

        racingGames: casual,
        shootGames: shooter,
        girlsGames: girls,
        shareStauts: false,
        recommendGameList,
        midGameList,
        newGameList,
        bigGameList,
        delicateGames,
        labelHide: false,

        gameChannelId: 4163,

        mobile: true,

        poster: '',
        poster2: '',

        yAxis: 0,
        left: 0,
        currentLeft: 0,

        yAxis2: 0,
        left2: 0,
        currentLeft2: 0,

        yAxis3: 0,
        left3: 0,
        currentLeft3: 0,

        isScroll: false,

        mouseDownTime: 0,
        mouseUpTime: 0,

        accountInfo: {},

        searchResult: [],
        search: '',
        searchDone: false,
        showSearchTable: false,
      
        camp: '',
        groupId: ''
      }
    },
    watch: {
      search(val) {
        this.searchGames()
      }
    },
    computed: {
      slideStyle() {
        return {
          transform: `translate3d(${this.left}px, 0, 0)`,
        }
      },
      slideStyle2() {
        return {
          transform: `translate3d(${this.left2}px, 0, 0)`,
        }
      },
      slideStyle3() {
        return {
          transform: `translate3d(${this.left3}px, 0, 0)`,
        }
      }
    },
    methods: {
      handleDetail(item) {
        if (this.isScroll) { return }
        if (this.gameChannelId == 5972) {
          return `detail.html?gameChannelId=${this.gameChannelId}&gameId=${item.gameId}${this.camp}${this.groupId}`;
        } else {
          return `detail.html?gameChannelId=${this.gameChannelId}&gameId=${item.gameId}`;
        }
      },
      handleTypeGames(type) {
        if (this.gameChannelId == 5972) {
          return `type.html?gameChannelId=${this.gameChannelId}&type=${type}${this.camp}${this.groupId}`
        } else {
          return `type.html?gameChannelId=${this.gameChannelId}&type=${type}`;
        }
      },
      handleToAboutContent(type) {
        if (this.gameChannelId == 5972) {
          return `about_content.html?aboutContentType=${type}${this.camp}${this.groupId}`;
        } else {
          return `about_content.html?aboutContentType=${type}`;
        }
      },
      handleToSearch() {
        let url = ''
        if (this.gameChannelId == 5972) {
          url = `search.html?gameChannelId=${this.gameChannelId}&keyword=${this.search}${this.camp}${this.groupId}`
        } else {
          url = `search.html?gameChannelId=${this.gameChannelId}&keyword=${this.search}`
        }
        location.href = url
      },
      searchGames: debounce(function () {
        this.searchDone = false
        axios({
          method: "post",
          url: "https://www.migame.vip/gamefront/gameList/search",
          data: {
            gameName: this.search,
            isTop: -1,
            limit: 10,
            page: 1,
          }
        }).then(res => {
          this.searchResult = res.data.data
          this.searchDone = true
        })
      }, 500),
      loadGAScript() {
        var adjs = document.createElement('script')
        adjs.async = 'async'
        adjs.src = `https://www.googletagmanager.com/gtag/js?id=${this.accountInfo.ga}`

        document.body.append(adjs)

        if (this.accountInfo.ga2.length) {
          var adjs1 = document.createElement('script')
          adjs1.async = 'async'
          adjs1.src = `https://www.googletagmanager.com/gtag/js?id=${this.accountInfo.ga2}`

          document.body.append(adjs1)
        }
      },
      handleBackTop() {
        let top = document.documentElement.scrollTop || document.body.scrollTop;
        // 实现滚动效果
        document.documentElement.scrollTop = 0
      },
      windowScrollEvent() {
        const el = document.documentElement || document.body;
        // 为窗口添加滑动监听事件，判断是否触底
        window.addEventListener('scroll', () => {
          const top = el.scrollTop
          const height = el.clientHeight
          const scrollHeight = el.scrollHeight
          if (Number.parseInt(top + height) >= scrollHeight) {
            this.reachBottom()
          }
        })
      },
      reachBottom() {
        this.loadMoreGames()
      },
      loadMoreGames() {
        this.moreGames.push(...loadMoreGames.splice(0, 8))
      },
      siwperMouseDown3(e) {
        this.mouseDownTime = 0
        this.mouseUpTime = 0
        const swiperContainer = this.$refs.swiperContainer3
        this.yAxis3 = e.clientX
        swiperContainer.style.transition = ''
        swiperContainer.onmousemove = this.swiperMouseLeave3

        this.mouseDownTime = new Date().getTime()
      },
      swiperMouseLeave3(e) {
        const swiperContainer = this.$refs.swiperContainer3
        const isLeftScroll = this.yAxis3 > e.clientX
        const isRightScroll = this.yAxis3 < e.clientX
        let scrollDistance = 0
        const last = (Math.abs(this.left3) + 1000) < swiperContainer.scrollWidth
        if (isLeftScroll && last) {
          scrollDistance = Math.abs(this.yAxis3 - e.clientX) + this.currentLeft3
          this.left3 = -(scrollDistance)
        }
        if (isRightScroll && this.left3 < 0) {
          scrollDistance = Math.abs(this.yAxis3 - e.clientX) - this.currentLeft3
          this.left3 = scrollDistance
        }
        e.preventDefault()
      },
      clearMouseMove3() {
        this.$nextTick(() => {
          const swiperContainer = this.$refs.swiperContainer3
          swiperContainer.onmousemove = null
          if (this.left3 > 0) {
            this.left3 = 0
            swiperContainer.style.transition = 'all 300ms ease-in-out'
          }
          this.currentLeft3 = Math.abs(this.left3)
          this.yAxis3 = 0
        })
        this.mouseUpTime = new Date().getTime()
        this.checkIsScroll()
      },
      handleScrollLeft3() {
        this.$nextTick(() => {
          const swiperContainer = this.$refs.swiperContainer3
          if (this.left3 < 0) {
            this.left3 += 300
          }
          if (this.left3 > 0) {
            this.left3 = 0
          }
          swiperContainer.style.transition = 'all 300ms ease-in-out'
        })
      },
      handleScrollRight3() {
        this.$nextTick(() => {
          const swiperContainer = this.$refs.swiperContainer3
          const swiperMainWidth = 1230
          if ((Math.abs(this.left3) + swiperMainWidth) < swiperContainer.scrollWidth) {
            this.left3 -= 300
          }
          swiperContainer.style.transition = 'all 300ms ease-in-out'
        })
      },

      siwperMouseDown2(e) {
        this.mouseDownTime = 0
        this.mouseUpTime = 0
        const swiperContainer = this.$refs.swiperContainer2
        this.yAxis2 = e.clientX
        swiperContainer.style.transition = ''
        swiperContainer.onmousemove = this.swiperMouseLeave2

        this.mouseDownTime = new Date().getTime()
      },
      swiperMouseLeave2(e) {
        const swiperContainer = this.$refs.swiperContainer2
        const isLeftScroll = this.yAxis2 > e.clientX
        const isRightScroll = this.yAxis2 < e.clientX
        let scrollDistance = 0
        const last = (Math.abs(this.left2) + 1000) < swiperContainer.scrollWidth
        if (isLeftScroll && last) {
          scrollDistance = Math.abs(this.yAxis2 - e.clientX) + this.currentLeft2
          this.left2 = -(scrollDistance)
        }
        if (isRightScroll && this.left2 < 0) {
          scrollDistance = Math.abs(this.yAxis2 - e.clientX) - this.currentLeft2
          this.left2 = scrollDistance
        }
        e.preventDefault()
      },
      clearMouseMove2() {
        this.$nextTick(() => {
          const swiperContainer = this.$refs.swiperContainer2
          swiperContainer.onmousemove = null
          if (this.left2 > 0) {
            this.left2 = 0
            swiperContainer.style.transition = 'all 300ms ease-in-out'
          }
          this.currentLeft2 = Math.abs(this.left2)
          this.yAxis2 = 0
        })
        this.mouseUpTime = new Date().getTime()
        this.checkIsScroll()
      },
      handleScrollLeft2() {
        this.$nextTick(() => {
          const swiperContainer = this.$refs.swiperContainer2
          if (this.left2 < 0) {
            this.left2 += 300
          }
          if (this.left2 > 0) {
            this.left2 = 0
          }
          swiperContainer.style.transition = 'all 300ms ease-in-out'
        })
      },
      handleScrollRight2() {
        this.$nextTick(() => {
          const swiperContainer = this.$refs.swiperContainer2
          const swiperMainWidth = 1230
          if ((Math.abs(this.left2) + swiperMainWidth) < swiperContainer.scrollWidth) {
            this.left2 -= 300
          }
          swiperContainer.style.transition = 'all 300ms ease-in-out'
        })
      },


      checkIsScroll() {
        const timeDiff = this.mouseUpTime - this.mouseDownTime
        if (timeDiff > 300) {
          this.isScroll = true
        } else {
          this.isScroll = false
        }
      },
      siwperMouseDown(e) {
        this.mouseDownTime = 0
        this.mouseUpTime = 0
        const swiperContainer = this.$refs.swiperContainer
        this.yAxis = e.clientX
        swiperContainer.style.transition = ''
        swiperContainer.onmousemove = this.swiperMouseLeave
        this.mouseDownTime = new Date().getTime()
      },
      swiperMouseLeave(e) {
        const swiperContainer = this.$refs.swiperContainer
        const isLeftScroll = this.yAxis > e.clientX
        const isRightScroll = this.yAxis < e.clientX
        let scrollDistance = 0
        const last = (Math.abs(this.left) + 1000) < swiperContainer.scrollWidth
        if (isLeftScroll && last) {
          scrollDistance = Math.abs(this.yAxis - e.clientX) + this.currentLeft
          this.left = -(scrollDistance)
        }
        if (isRightScroll && this.left < 0) {
          scrollDistance = Math.abs(this.yAxis - e.clientX) - this.currentLeft
          this.left = scrollDistance
        }
        e.preventDefault()
      },
      clearMouseMove() {
        this.$nextTick(() => {
          const swiperContainer = this.$refs.swiperContainer
          swiperContainer.onmousemove = null
          if (this.left > 0) {
            this.left = 0
            swiperContainer.style.transition = 'all 300ms ease-in-out'
          }
          this.currentLeft = Math.abs(this.left)
          this.yAxis = 0
        })
        this.mouseUpTime = new Date().getTime()
        this.checkIsScroll()
      },
      handleScrollLeft() {
        this.$nextTick(() => {
          const swiperContainer = this.$refs.swiperContainer
          if (this.left < 0) {
            this.left += 300
          }
          if (this.left > 0) {
            this.left = 0
          }
          swiperContainer.style.transition = 'all 300ms ease-in-out'
        })
      },
      handleScrollRight() {
        this.$nextTick(() => {
          const swiperContainer = this.$refs.swiperContainer
          const swiperMainWidth = 1230
          if ((Math.abs(this.left) + swiperMainWidth) < swiperContainer.scrollWidth) {
            this.left -= 300
          }
          swiperContainer.style.transition = 'all 300ms ease-in-out'
        })
      },
      handleSetNewsGame(ind) {
        var domBox = document.getElementsByClassName('box-container')
        for (var i = 0; i < domBox.length; i++) {
          domBox[i].className = 'box-container scroll'
        }
        domBox[ind].classList.add('a')
      },
      handleShare() {
        this.shareStauts = !this.shareStauts
        if (this.shareStauts) {
          document.body.style.overflow = "hidden"
        } else {
          document.body.style.overflow = "auto"
        }
      },
      handleHideLabel() {
        this.labelHide = !this.labelHide
      },
      handleScroll() {
        var imgs = document.querySelectorAll('.pic')
        var game_items = document.querySelectorAll(".scroll")
        let scrolltop = document.documentElement.scrollTop || document.body.scrollTop;
        scrolltop > 50 ? this.backTop = true : this.backTop = false
        for (var i = 0; i < imgs.length; i++) {
          if ((window.innerHeight + scrolltop) > this.lazyload(game_items[i])) {
            (i => {
              setTimeout(() => {
                var temp = new Image()
                temp.src = imgs[i].getAttribute("data-src")
                temp.onload = () => {
                  imgs[i].src = imgs[i].getAttribute("data-src")
                }
              }, 100)
            })(i)
          }
        }
      },
      lazyload(e) {
        if (e != undefined) {
          return e.offsetTop
        }
      },
      getAdData() {
        var adjs = document.createElement('script')
        adjs.async = 'async'
        adjs.src = 'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1727029308377024'
        adjs.crossorigin = 'anonymous'
        adjs.setAttribute("data-ad-frequency-hint", "30s");
        adjs.setAttribute("data-ad-channel", this.accountInfo.adChannel);
        // adjs.setAttribute("data-adbreak-test","on");

        document.head.append(adjs)
      },
      throttle(fn, delay) {
        let timer = null
        return function () {
          let that = this
          let args = arguments
          if (timer) {
            return
          }
          timer = setTimeout(() => {
            fn.apply(that, args)
            clearTimeout(timer)
            timer = null
          }, delay)
        }
      },
      getQueryVariable(variable) {
        var query = window.location.search.substring(1);
        var vars = query.split("&");
        for (var i = 0; i < vars.length; i++) {
          var pair = vars[i].split("=");
          if (pair[0] == variable) { return pair[1]; }
        }
        return (false);
      },
      addDelicateGames() {
        this.delicateGames.push({
          "gameId": "2835",
          "gameType": "Puzzle,New",
          "gameName": "My Top War",
          "fileName": "MyTopWar",
          "gameLogo": "./webp/007470b21ce7402fb26dfecdeb92510e.Webp",
          "gamePlayNumber": "100038",
          "gameDesc": "Welcome to My Top War. Start on a barren, deserted island and build an idyllic base to train your armies, improve your power and liberate the land. Strength doesn't come from just troops, and that's a good thing! Create a stylish yet formidable island with a variety of buildings and decorations at your disposal. Come and show-off your unique style!",
          "vidUrl": ""
        },
          {
            "gameId": "2081",
            "gameType": "Puzzle,New",
            "gameName": "Diy Keyboard",
            "fileName": "DiyKeyboard",
            "gameLogo": "./webp/64b7e423677746a89427a8a97aa4332e.webp",
            "gameDetailsImg": "https://gamedesc.91onegame.com/9052198b35df482696b7d0df814d899e.png",
            "gamePlayNumber": "100030",
            "gameDesc": "Make your own custom keyboard art that everyone will love!\nDIY Keyboard 3D is an art game where you can use your creativity to become a keyboard designer and make your own custom keyboard!\nThere are various gameplay options to help you make a custom keyboard art masterpiece the way you like!\nChoose your favorite color or design to decorate each part of the keyboard art masterpiece.\nDIY keyboard 3D games will give you the easiest way to make your own keyboard and become the designer who creates the best custom keyboard ever!"
          },
          {
            "gameId": "2860",
            "gameType": "New,Action",
            "gameName": "One Line",
            "fileName": "OneLine",
            "gameLogo": "./webp/621de57f275849cebf82d8b6cdda5989.webp",
            "gameDetailsImg": "https://gamedesc.91onegame.com/0e1881042d6d450a8dd978edda4ea5f2.png",
            "gamePlayNumber": "100000",
            "gameDesc": "Draw freely and help them.\nThe line you draw will become 3D.\nFrom the rain,\nFrom rocks and bombs attacking,\nPlease draw well and protect them."
          })
      },
      loadingAdsense() {
        var ele = document.createElement("script");
        var ele2 = document.createElement("script");

        if (window.screen.width > 768) {
          this.mobile = false
          this.poster = `<ins class="adsbygoogle" style="display:block" 
        data-ad-client="ca-pub-1727029308377024" data-ad-slot="${this.accountInfo.pc.home.top}" data-ad-format="auto" data-full-width-responsive="true"><\/ins>`

          this.poster2 = `<ins class="adsbygoogle" v-else style="display:block" data-ad-client="ca-pub-1727029308377024" data-ad-slot="${this.accountInfo.pc.home.bottom}" data-ad-format="auto" data-full-width-responsive="true"><\/ins>`
        } else {
          this.poster = `<ins class="adsbygoogle" style="display:inline-block;width:320px;height:100px;" 
        data-ad-client="ca-pub-1727029308377024" data-ad-slot="${this.accountInfo.mobile.home.top}"><\/ins>`

          this.poster2 = `<ins class="adsbygoogle" v-if="mobile" style="display:inline-block;width:320px;height:100px;" data-ad-client="ca-pub-1727029308377024" data-ad-slot="${this.accountInfo.mobile.home.bottom}"><\/ins>`
        }

        ele.innerHTML = '(adsbygoogle = window.adsbygoogle || []).push({});'
        ele2.innerHTML = '(adsbygoogle = window.adsbygoogle || []).push({});'

        this.$refs.poster.append(ele)
        this.$refs.poster2.append(ele2)
      }
    },
    created() {
      this.gameChannelId = this.getQueryVariable('gameChannelId') ? this.getQueryVariable('gameChannelId') : 4163
      this.accountInfo = googleAccount.hasOwnProperty(this.gameChannelId) ? googleAccount[this.gameChannelId] : googleAccount[4163]
      this.loadGAScript()

      if (window.screen.width < 768) {
        this.addDelicateGames()
        if (this.gameChannelId==5370) {
    sendDataIfNotSent(this.gameChannelId); 
}else if(this.gameChannelId==5971){
    sendDataIfNotSent(this.gameChannelId);
}else if(this.gameChannelId==5441){
    sendDataIfNotSent(this.gameChannelId);
}
      }

      if (window.localStorage.getItem('__lsv__')) {
        window.localStorage.removeItem('__lsv__')
      }

      if (this.gameChannelId == 5972) {
        const camp = this.getQueryVariable('camp')
        const groupId = this.getQueryVariable('groupId')
        this.camp = camp ? `&camp=${camp}` : ''
        this.groupId = groupId ? `&groupId=${groupId}` : ''
      }
    },
    mounted() {
      this.windowScrollEvent()
      adPrepare()
      createScript()

      window.addEventListener("scroll", this.handleScroll, true)

      setTimeout(() => {
        this.handleScroll()
      }, 16);
      this.handleSetNewsGame(0)


      this.$nextTick(() => {
        this.getAdData()
        this.loadingAdsense()
      })
    },
  })
</script>


<script>
  window.dataLayer = window.dataLayer || [];
  function gtag() { dataLayer.push(arguments); }
  gtag('js', new Date());

  gtag('config', vm.accountInfo.ga);
  if (vm.accountInfo.ga2.length) {
    gtag('config', vm.accountInfo.ga2);
  }
</script>

<!-- Hotjar Tracking Code for my site -->
<script>
  if (vm.gameChannelId == 4163) {
    (function (h, o, t, j, a, r) {
      h.hj = h.hj || function () { (h.hj.q = h.hj.q || []).push(arguments) };
      h._hjSettings = { hjid: 3378431, hjsv: 6 };
      a = o.getElementsByTagName('head')[0];
      r = o.createElement('script'); r.async = 1;
      r.src = t + h._hjSettings.hjid + j + h._hjSettings.hjsv;
      a.appendChild(r);
    })(window, document, 'https://static.hotjar.com/c/hotjar-', '.js?sv=');
  }
</script>
<script>
  var pattern = /^aswif/;
    window.addEventListener('blur', function() {
        if (pattern.test(document.activeElement.id)) {
          gtag('event', 'clickAd')
        }
    })
</script>
</html>